<template>
  <div class="category">
    <!-- 商品分类 -->
    <el-card shadow="always" style="margin:30px" :body-style="{ padding: '20px',margin:'0 0 20px 0' }">
      <div slot="header">
        <span>分类管理</span>
      </div>
      <!-- card body -->
      <div class="title" style="margin-bottom:30px;">乐居分类:</div>
      <el-row :gutter="20">
        <el-col :span="6" :offset="0">
          <el-card shadow="always" :body-style="{ padding: '20px',margin:'0 0 20px 0' }">
            <div slot="header">
              <span>创意:</span>
            </div>
            <!-- card body -->
            <img style="width:287px; height:300px" src="" alt="">
          </el-card>
        </el-col>
        <el-col :span="6" :offset="0">
          <el-card shadow="always" :body-style="{ padding: '20px',margin:'0 0 20px 0' }">
            <div slot="header">
              <span>创意:</span>
            </div>
            <!-- card body -->
            <img style="width:287px; height:300px" src="" alt="">
          </el-card>
        </el-col>
        <el-col :span="6" :offset="0">
          <el-card shadow="always" :body-style="{ padding: '20px',margin:'0 0 20px 0' }">
            <div slot="header">
              <span>创意:</span>
            </div>
            <!-- card body -->
            <img style="width:287px; height:300px" src="" alt="">
          </el-card>
        </el-col>
        <el-col :span="6" :offset="0">
          <el-card shadow="always" :body-style="{ padding: '20px',margin:'0 0 20px 0' }">
            <div slot="header">
              <span>创意:</span>
            </div>
            <!-- card body -->
            <img style="width:287px; height:300px" src="" alt="">
          </el-card>
        </el-col>
      </el-row>
      <div class="title" style="margin-bottom:30px;">全部分类:</div>

      <el-table
        :data="list"
        style="width: 100%;margin-bottom: 20px;"
        row-key="id"
        border
        :tree-props="{children: 'children', hasChildren: 'hasChildren'}"
      >
        <el-table-column
          prop="name"
          label="菜单名称"
          width="180"
        />
        <el-table-column
          prop="icon"
          label="icon"
          width="180"
          align="center"
        >
          <template slot-scope="scope">
            <img style="width:60px; height:60px" :src="scope.row.icon" alt="">
          </template>
        </el-table-column>
        <el-table-column
          prop="keywords"
          label="分类名字"
          align="center"
        />
        <el-table-column
          prop="sort"
          label="排序"
          align="center"
        />
        <el-table-column
          prop="showStatus"
          label="显示状态"
          align="center"
        >
          <template slot-scope="scope">
            {{ scope.row.showStatus?'展示':'不展示' }}
          </template>
        </el-table-column>
        <el-table-column
          prop="navStatus"
          label="导航栏展示"
          align="center"
        >
          <template slot-scope="scope">
            {{ scope.row.navStatus?'展示':'不展示' }}
          </template>
        </el-table-column>
        <el-table-column
          prop="description"
          label="描述"
          align="center"
        />
        <el-table-column
          prop="modifyTime"
          label="创建时间"
          align="center"
        />
      </el-table>
    </el-card>

  </div>
</template>

<script>
import { getAllCategory as getAllCategoryApi } from '@/api/product/category/index'
export default {
  components: {

  },
  props: {

  },
  data() {
    return {
      list: []

    }
  },
  computed: {

  },
  watch: {

  },
  created() {
    getAllCategoryApi().then(res => {
      console.log(res)
      const { message: errMsg, success, data } = res
      if (success) {
        const arr = []
        data.items.forEach(el => {
          console.log(el)
          el.category.children = el.children
          arr.push(el.category)
        })
        this.list = arr
        console.log(this.list)
      } else {
        this.$message.error(errMsg)
      }
    })
  },
  mounted() {

  },
  methods: {

  }
}
</script>

<style scoped lang="scss">
.title{
  color: rgba(0,0,0,.85);
  font-weight: 700;
  font-size: 16px;
  margin-top: 20px;
}
</style>
